package se.jocke.nbrs.ui.action;

import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.Lookup;
import se.jocke.nbrs.service.RestServiceManager;

/**
 *
 * @author jocke
 */
public class AddNewRestServiceGroupAction extends AbstractAction {

    public AddNewRestServiceGroupAction() {
        super("add new rest service group");
    }

    @Override
    public void actionPerformed(ActionEvent e) {

        NotifyDescriptor.InputLine discriptor = new NotifyDescriptor.InputLine(
                "Create a new rest service group",
                "New rest service group",
                NotifyDescriptor.OK_CANCEL_OPTION,
                NotifyDescriptor.INFORMATION_MESSAGE);

        if (DialogDisplayer.getDefault().notify(discriptor) == NotifyDescriptor.OK_OPTION && discriptor.getInputText() != null && !discriptor.getInputText().isEmpty()) {
            Lookup.getDefault().lookup(RestServiceManager.class).addNewGroup(discriptor.getInputText());
        }

    }

}
